<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
    <style>
        div{
            width: 300px;
            height: 300px;
            background-color: pink;
        }

        .box{
            display: none;
        }
    </style>
<body>
    <button>点击</button>
    <div></div>

    <script>
        // 3. 页面有一个元素， 点击按钮,  元素在显示隐藏中切换
        const btn = document.getElementsByTagName('button')[0]
        const div = document.getElementsByTagName('div')[0]

        btn.onclick = () => {
            div.classList.toggle('box')
        }

    </script>
</body>

</html>